package com.angel.bo.business.controller;


import com.angel.bo.auth.client.annotation.IgnoreUserToken;
import com.angel.bo.beans.webstart.WebStart;
import com.angel.bo.business.service.WebStartService;
import com.angel.bo.common.msg.WebReturn;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@RequestMapping("/webStart")
@Api(value = "WebStartController",description = "启动webstart",tags = "webStart")
public class WebStartController {

    @Autowired
    private WebStartService webStartService;



    @RequestMapping(value = "/webExecuteO",method = RequestMethod.GET)
    @ApiOperation(value = "web执行java")
    @IgnoreUserToken
    public String webExecuteO(WebStart webStart){

        WebReturn webReturn = webStartService.dynamicGenerationJNLP(webStart);
        return webReturn.getData().toString();
    }

    @GetMapping("/downloadWebExecuteOJar/{jarName:.+}")
    @IgnoreUserToken
    public void downloadWebExecuteOJar(@PathVariable("jarName") String jarName, HttpServletRequest request, HttpServletResponse response) throws IOException {

        webStartService.downloadWebExecuteOJar(jarName,request,response);

    }

}
